package com.zHan.mapper;

import com.zHan.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * 员工管理
 */
@Mapper
public interface EmpMapper {

    int deleteByIds(List<Integer> ids);

    /*//传统方法
    @Select("select * from emp limit #{start},#{pageSize}")
    List<Emp> page(Integer start,Integer pageSize);


    @Select("select count(*) from emp")
    Long count();*/

    //使用PageHelper
    //@Select("select * from emp")
    List<Emp> page(String name, Short gender, LocalDate begin, LocalDate end);

    @Insert("insert into emp(username, name, gender,image, job, entrydate,dept_id,create_time,update_time) " +
            "VALUES (#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime} ) ")
    int insert(Emp emp);

    @Select("select * from emp where id=#{id}")
    Emp selectById(Integer id);

    int update(Emp emp);

    @Select("select id, username, password, name, gender, image, job, entrydate, dept_id, create_time, update_time" +
            " from emp where username=#{username} and password=#{password}")
    Emp selectUsernameAndPassword(Emp emp);

    @Delete("delete from emp where dept_id=#{DeptId}")
    void deleteByDeptId(Integer DeptId);
}
